package Chain;

import java.util.ArrayList;
import java.util.List;

public abstract class AFruitSort {
    private int weight;
    protected List<String> fruitBox;
    private AFruitSort nextFruitSort;
    public void getFruitBox(){
        System.out.println("Weight:" + weight);
        System.out.println("个数:"+fruitBox.size());
        for(String t:fruitBox){
            System.out.println(t+",");
        }
        System.out.println(" ");
    }
    public AFruitSort(int weight){
        this.weight = weight;
        fruitBox = new ArrayList<String>();
    }
    public void setNextSort(AFruitSort nextFruitSort){
        this.nextFruitSort = nextFruitSort;
    }
    public void sendFruit(int weight,String fruit){
        if(this.weight <= weight){
            pushBox(fruit);
        } else if (nextFruitSort != null) {
            nextFruitSort.sendFruit(weight, fruit);
            
        }

    }
    abstract protected void pushBox(String fruit);
}
